home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / sharewar / slunec / app / httrack.exe / {app} / src_win / WinHTTrack / WinHTTrack.cpp < prev    next >
C/C++ Source or Header  |  2002-06-06  |  21KB  |  849 lines

  1. // WinHTTrack.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "WinHTTrack.h"
  6.  
  7. #include "Shell.h"
  8. #include "winsock.h"
  9.  
  10. #include "wid1.h"
  11. #include "maintab.h"
  12.  
  13. #include "MainFrm.h"
  14. #include "splitter.h"
  15. #include "about.h"
  16.  
  17. #include "WinHTTrackDoc.h"
  18. #include "WinHTTrackView.h"
  19.  
  20. #include "inprogress.h"
  21.  
  22. /* HTS - HTTRACK */
  23. #include "htsglobal.h"
  24.  
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30.  
  31. //
  32. #include "DialogContainer.h"
  33. #include "InfoUrl.h"
  34.  
  35. // PAS de domodal a l'exterieur!!!!!
  36. #include "wizard.h"
  37. #include "wizard2.h"
  38. #include "WizLinks.h"
  39. extern char WIZ_question[1000];
  40. extern char WIZ_reponse[1000];
  41.  
  42.  
  43. extern Wid1* dialog1;
  44. extern CMainTab* maintab;
  45. extern Cinprogress* inprogress;
  46. extern CShellApp* CShellApp_app;
  47. extern int termine;
  48. extern int termine_requested;
  49. extern int soft_term_requested;
  50. extern int shell_terminated;
  51. extern CInfoUrl* _Cinprogress_inst;
  52. extern int LibRasUse;
  53.  
  54. extern "C" {
  55.   char* hts_rootdir(char* file);
  56. };
  57.  
  58.  
  59. // rmdir
  60. #include <direct.h>
  61.  
  62. // linput
  63. extern "C" {
  64.   void linput(FILE* fp,char* s,int max);
  65.   void linput_trim(FILE* fp,char* s,int max);
  66.   void linput_cpp(FILE* fp,char* s,int max);
  67. };
  68.  
  69. /* WinHTTrack refresh Mutex */
  70. HANDLE WhttMutex;
  71.  
  72. /* Location */
  73. char* WhttLocation="";
  74.  
  75.  
  76. // HTTrack main vars
  77. HWND App_Main_HWND;
  78. CSplitterFrame* this_CSplitterFrame=NULL;
  79. HICON httrack_icon;
  80. // Helper
  81. LaunchHelp* HtsHelper=NULL;
  82.  
  83. // dirtreeview
  84. #include "DirTreeView.h"
  85. extern CDirTreeView* this_DirTreeView;
  86.  
  87. // New Project
  88. #include "NewProj.h"
  89. extern CNewProj* dialog0;
  90.  
  91.  
  92. // InfoEnd
  93. #include "infoend.h"
  94. extern Cinfoend* this_Cinfoend;
  95.  
  96. // Pointeur sur nous
  97. CWinHTTrackApp* this_app=NULL;
  98.  
  99. // fexist
  100. extern "C" int fexist(char*);
  101.  
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CWinHTTrackApp
  104.  
  105. BEGIN_MESSAGE_MAP(CWinHTTrackApp, CWinApp)
  106.     //{{AFX_MSG_MAP(CWinHTTrackApp)
  107.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  108.     ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  109.     ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  110.     ON_COMMAND(ID_FILE_MRU_FILE1, OnFileMruFile1)
  111.     //}}AFX_MSG_MAP
  112.   ON_COMMAND(wm_ViewRestart,OnViewRestart)
  113.   ON_COMMAND(wm_WizRequest1,OnWizRequest1)
  114.   ON_COMMAND(wm_WizRequest2,OnWizRequest2)
  115.   ON_COMMAND(wm_WizRequest3,OnWizRequest3)
  116.     // Standard file based document commands
  117.     //ON_COMMAND(ID_FILE_WIZARD, OnWizard)
  118.     ON_COMMAND(ID_FILE_NEW, OnFileNew)
  119.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  120.     ON_COMMAND(ID_FILE_DELETE_PROJ, OnFileDelete)
  121.     ON_COMMAND(ID_FILE_BROWSE_SIT, OnBrowseWebsites)
  122.   ON_COMMAND(IDC_langprefs,Onipabout)
  123.   ON_COMMAND(ID_ABOUT,Onipabout)
  124.   ON_COMMAND(ID_UPDATE,OnUpdate)
  125.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  126.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  127.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  128.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  129.   // Forward to inprogress
  130.   ON_BN_CLICKED(ID_LOAD_OPTIONS,FwOnLoadprofile)
  131.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,FwOnSaveprofile)
  132.     ON_BN_CLICKED(ID_LoadDefaultOptions, FwOnLoaddefault)
  133.     ON_BN_CLICKED(ID_SaveDefaultOptions, FwOnSavedefault)
  134.     ON_BN_CLICKED(ID_ClearDefaultOptions,FwOnResetdefault)
  135.   //
  136.   ON_BN_CLICKED(ID_WINDOW_HIDE,FwOnhide)
  137.   //
  138.     ON_BN_CLICKED(ID_OPTIONS_MODIFY,FwOnModifyOpt)
  139.     ON_BN_CLICKED(ID_FILE_PAUSE,FwOnPause)
  140.     ON_BN_CLICKED(ID_LOG_VIEWLOG,FwOniplogLog)
  141.     ON_BN_CLICKED(ID_LOG_VIEWERRORLOG,FwOniplogErr)
  142.     ON_BN_CLICKED(ID_LOG_VIEWTRANSFERS,FwOnViewTransfers)
  143. END_MESSAGE_MAP()
  144.  
  145. /////////////////////////////////////////////////////////////////////////////
  146. // CWinHTTrackApp construction
  147.  
  148. CWinHTTrackApp::CWinHTTrackApp()
  149. {
  150.   // HTTrack inits
  151.   CreateMutex(NULL, FALSE, "WinHTTrack_RUN");
  152.   HtsHelper = new LaunchHelp();
  153. }
  154.  
  155. CWinHTTrackApp::~CWinHTTrackApp()
  156. {
  157.   DeleteTabs();
  158.   delete HtsHelper;
  159.   HtsHelper=NULL;
  160. }
  161.  
  162. /////////////////////////////////////////////////////////////////////////////
  163. // The one and only CWinHTTrackApp object
  164.  
  165. CWinHTTrackApp theApp;
  166.  
  167. /////////////////////////////////////////////////////////////////////////////
  168. // CWinHTTrackApp initialization
  169.  
  170. int Eval_Exception( void );
  171.  
  172. int Eval_Exception ( int n_except )
  173. {
  174.     AfxMessageBox("error");
  175.  
  176.     return 0;
  177. }
  178.  
  179. extern "C" {
  180.   int hts_init(void);
  181.   void hts_uninit(void);
  182. }
  183. BOOL CWinHTTrackApp::InitInstance()
  184. {
  185.   hts_init();
  186.  
  187.   WhttMutex = CreateMutex(NULL,FALSE,NULL);
  188.  
  189.   // Change the registry key under which our settings are stored.
  190.   // TODO: You should modify this string to be something appropriate
  191.   // such as the name of your company or organization.
  192.   SetRegistryKey("WinHTTrack Website Copier");
  193.   LANG_INIT();    // petite init langue
  194.   
  195.   /* INDISPENSABLE pour le drag&drop! */
  196.   if (!AfxOleInit())
  197.   {
  198.       AfxMessageBox(LANG(LANG_F1));
  199.       return FALSE;
  200.   }
  201.   AfxEnableControlContainer();
  202.   
  203.   // Pointeur sur CShellApp
  204.   CShellApp_app=&app;
  205.   this_app=this;
  206.   _Cinprogress_inst=NULL;
  207.   LibRasUse=0;
  208.  
  209.     // Standard initialization
  210.     // If you are not using these features and wish to reduce the size
  211.     //  of your final executable, you should remove from the following
  212.     //  the specific initialization routines you do not need.
  213.  
  214. #ifdef _AFXDLL
  215.     Enable3dControls();            // Call this when using MFC in a shared DLL
  216. #else
  217.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  218. #endif
  219.  
  220.  
  221.   httrack_icon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  222.  
  223.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  224.  
  225.     // Register the application's document templates.  Document templates
  226.     //  serve as the connection between documents, frame windows and views.
  227.  
  228.   // DOC //
  229.     CMultiDocTemplate* pDocTemplate;
  230.     pDocTemplate = new CMultiDocTemplate(
  231.         IDR_MAINFRAME,
  232.         RUNTIME_CLASS(CWinHTTrackDoc),
  233.         RUNTIME_CLASS(CSplitterFrame),       // main SDI frame window
  234.         RUNTIME_CLASS(CView)); 
  235.     AddDocTemplate(pDocTemplate);
  236.  
  237.   /*
  238.     CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
  239.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  240.         return FALSE;
  241.   */
  242.  
  243.     // create main window
  244.     CMainFrame* pMainFrame = new CMainFrame;
  245.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  246.         return FALSE;
  247.     m_pMainWnd = pMainFrame;
  248.     int nCmdShow = m_nCmdShow;
  249.  
  250.  
  251.   // Also in this example, there is only one menubar shared between
  252.     //  all the views.  The automatic menu enabling support of MFC
  253.     //  will disable the menu items that don't apply based on the
  254.     //  currently active view.  The one MenuBar is used for all
  255.     //  document types, including when there are no open documents.
  256.  
  257.   // enable file manager drag/drop and DDE Execute open
  258.     pMainFrame->DragAcceptFiles();
  259.  
  260.   // Now finally show the main menu
  261.     //pMainFrame->ShowWindow(m_nCmdShow);
  262.     //pMainFrame->UpdateWindow();
  263.     m_pMainWnd = pMainFrame;
  264.  
  265.   // command line arguments are ignored, create a new (empty) document
  266.     //OnFileNew();
  267.   // DOC //
  268.  
  269.     // Parse command line for standard shell commands, DDE, file open
  270.     CCommandLineInfo cmdInfo;
  271.     ParseCommandLine(cmdInfo);
  272.  
  273.   hts_rootdir((char*)AfxGetApp()->m_pszHelpFilePath);
  274.  
  275.   // Restore position
  276.     ((CMainFrame*)m_pMainWnd)->InitialShowWindow(nCmdShow);
  277.     pMainFrame->UpdateWindow();
  278.  
  279.     // Dispatch commands specified on the command line
  280.     if (!ProcessShellCommand(cmdInfo))
  281.         return FALSE;
  282.  
  283.   // Init Winsock
  284.   WSockInit();
  285.  
  286.     // The one and only window has been initialized, so show and update it.
  287.     //m_pMainWnd->ShowWindow(SW_SHOW);
  288.     //m_pMainWnd->UpdateWindow();
  289.  
  290.   /*CWinApp* app=AfxGetApp();
  291.   POSITION pos;
  292.   pos=app->GetFirstDocTemplatePosition();
  293.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  294.   pos=templ->GetFirstDocPosition();
  295.   CDocument* doc  = templ->GetNextDoc(pos);
  296.  
  297.   CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CTest );
  298.   CObject* pObject = pRuntimeClass->CreateObject();
  299.   ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CTest ) ) );
  300.   
  301.   doc->AddView((CView*) pObject);
  302.   */
  303.  
  304.   {
  305.     // Infos la 1ere fois!
  306.     CWinApp* pApp = AfxGetApp();
  307.     if (pApp->GetProfileInt("Interface","FirstRun",0) != 3) {
  308.       pApp->WriteProfileInt("Interface","FirstRun",3);
  309.  
  310.       // enable file manager drag/drop and DDE Execute open
  311.       EnableShellOpen();
  312.       RegisterShellFileTypes();
  313.       // register "New File" handler
  314.       HKEY phkResult;
  315.       DWORD creResult;
  316.       if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  317.         RegCloseKey(phkResult);
  318.         if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt\\ShellNew",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  319.           char voidbuff='\0';
  320.           RegSetValueEx(phkResult,"NullFile",0,REG_SZ,(LPBYTE)&voidbuff,1);
  321.           RegCloseKey(phkResult);
  322.         }
  323.       }     
  324.  
  325.       Cabout about;
  326.       about.DoModal();
  327.       
  328.       // Default proxy?
  329.       if (maintab) {
  330.         maintab->DefineDefaultProxy();
  331.         if (maintab->DoModal()!=IDCANCEL) {
  332.           // Default proxy values
  333.           CString strSection       = "OptionsValues";
  334.           MyWriteProfileString("",strSection, "Proxy",maintab->m_option10.m_proxy);
  335.           MyWriteProfileString("",strSection, "Port",maintab->m_option10.m_port);
  336.         }
  337.         maintab->UnDefineDefaultProxy();
  338.       }
  339.     }
  340.   }
  341.   
  342.  
  343. #ifdef HTTRACK_AFF_WARNING
  344. #ifndef _DEBUG
  345.   AfxMessageBox("--WARNING--\r\n"HTTRACK_AFF_WARNING);
  346. #endif
  347. #endif
  348.  
  349.   return TRUE;
  350. }
  351.  
  352.  
  353. BOOL CWinHTTrackApp::WSockInit() {
  354.   // Initialiser WINSOCK
  355.   WORD   wVersionRequested; /* requested version WinSock API */ 
  356.   WSADATA wsadata;        /* Windows Sockets API data */
  357.   {
  358.     int stat;
  359.     wVersionRequested = 0x0101;
  360.     stat = WSAStartup( wVersionRequested, &wsadata );
  361.     if (stat != 0) {
  362.       //HTS_PANIC_PRINTF("Winsock not found!\n");
  363.     } else if (LOBYTE(wsadata.wVersion) != 1  && HIBYTE(wsadata.wVersion) != 1) {
  364.       //HTS_PANIC_PRINTF("WINSOCK.DLL does not support version 1.1\n");
  365.       WSACleanup();
  366.     }
  367.   }
  368.   // Fin Initialiser WINSOCK
  369.   return TRUE;
  370. }
  371.  
  372. /////////////////////////////////////////////////////////////////////////////
  373. // CAboutDlg dialog used for App About
  374.  
  375. /*
  376. class CAboutDlg : public CDialog
  377. {
  378. public:
  379.     CAboutDlg();
  380.  
  381. // Dialog Data
  382.     //{{AFX_DATA(CAboutDlg)
  383.     enum { IDD = IDD_ABOUTBOX };
  384.     //}}AFX_DATA
  385.  
  386.     // ClassWizard generated virtual function overrides
  387.     //{{AFX_VIRTUAL(CAboutDlg)
  388.     protected:
  389.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  390.     //}}AFX_VIRTUAL
  391.  
  392. // Implementation
  393. protected:
  394.     //{{AFX_MSG(CAboutDlg)
  395.         // No message handlers
  396.     //}}AFX_MSG
  397.     DECLARE_MESSAGE_MAP()
  398. };
  399.  
  400. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  401. {
  402.     //{{AFX_DATA_INIT(CAboutDlg)
  403.     //}}AFX_DATA_INIT
  404. }
  405.  
  406. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  407. {
  408.     CDialog::DoDataExchange(pDX);
  409.     //{{AFX_DATA_MAP(CAboutDlg)
  410.     //}}AFX_DATA_MAP
  411. }
  412.  
  413. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  414.     //{{AFX_MSG_MAP(CAboutDlg)
  415.         // No message handlers
  416.     //}}AFX_MSG_MAP
  417. END_MESSAGE_MAP()
  418. */
  419.  
  420. // App command to run the dialog
  421. void CWinHTTrackApp::OnAppAbout()
  422. {
  423.   Cabout about;
  424.   about.DoModal();
  425. //    CAboutDlg aboutDlg;
  426. //    aboutDlg.DoModal();
  427. }
  428.  
  429.  
  430. /* Request: Set new view in the splitter window (when clicking on finished, for example) */
  431. extern "C" {
  432.   int hts_resetvar(void);
  433. }
  434. void CWinHTTrackApp::OnViewRestart() {
  435.   //CloseAllDocuments(FALSE);
  436.   //OnFileNew();
  437.  
  438.   /* Free library */
  439.   WHTT_LOCK();
  440.   hts_resetvar();
  441.   WHTT_UNLOCK();
  442.  
  443.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  444. }
  445.  
  446. void CWinHTTrackApp::OnWizRequest1() {
  447.   wizard diawiz;
  448.   diawiz.m_question=WIZ_question;
  449.   diawiz.DoModal();
  450.   strcpy(WIZ_reponse,diawiz.m_reponse);
  451. }
  452.  
  453. void CWinHTTrackApp::OnWizRequest2() {
  454.   wizard2 diawiz2;
  455.   diawiz2.m_question=WIZ_question;
  456.   if (diawiz2.DoModal()==IDOK)
  457.   strcpy(WIZ_reponse,"YES");
  458.   else
  459.     strcpy(WIZ_reponse,"NO");
  460. }
  461.  
  462. void CWinHTTrackApp::OnWizRequest3() {
  463.   WizLinks diawiz3;
  464.   diawiz3.m_url=WIZ_question;
  465.   if (diawiz3.DoModal()==IDskipall)
  466.     strcpy(WIZ_reponse,"*");
  467.   else
  468.     switch(diawiz3.m_lnk) {
  469.     case 0:
  470.       strcpy(WIZ_reponse,"0");
  471.       break;
  472.     case 1:
  473.       strcpy(WIZ_reponse,"1");
  474.       break;
  475.     case 2:
  476.       strcpy(WIZ_reponse,"2");
  477.       break;
  478.     case 3:
  479.       strcpy(WIZ_reponse,"4");
  480.       break;
  481.     case 4:
  482.       strcpy(WIZ_reponse,"5");
  483.       break;
  484.     case 5:
  485.       strcpy(WIZ_reponse,"6");
  486.       break;
  487.     default:
  488.       strcpy(WIZ_reponse,"");
  489.       break;
  490.   }
  491. }
  492.  
  493.  
  494. //
  495.  
  496.  
  497. /////////////////////////////////////////////////////////////////////////////
  498. // CWinHTTrackApp message handlers
  499.  
  500. // Ne fait pas partie de la classe
  501. /*
  502. UINT RunBackEngine( LPVOID pP ) {
  503.   static int running=0;
  504.   if (running)
  505.     return 0;
  506.   running=1;
  507.   {
  508.     CWinApp* app=AfxGetApp();
  509.     POSITION pos;
  510.     pos=app->GetFirstDocTemplatePosition();
  511.     CDocTemplate* templ = app->GetNextDocTemplate(pos);
  512.     pos=templ->GetFirstDocPosition();
  513.     CDocument* doc  = templ->GetNextDoc(pos);
  514.     pos=doc->GetFirstViewPosition();
  515.     CView*     view = doc->GetNextView(pos);
  516.     App_Main_HWND=view->m_hWnd;
  517.   }
  518.   //
  519.   CShellApp app;
  520.   app.InitInstance();
  521.   running=0;
  522.   return 0;
  523. }
  524. */
  525.  
  526. /*
  527. void CWinHTTrackApp::OnWizard() {
  528.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  529. }
  530. */
  531.  
  532. afx_msg void CWinHTTrackApp::OnFileNew( ) {
  533.   OpenDocumentFile("");
  534. }
  535.  
  536. afx_msg void CWinHTTrackApp::OnFileOpen( ) {
  537.   this->CWinApp::OnFileOpen();
  538. }
  539.  
  540. void CWinHTTrackApp::OnFileSave() {
  541. }
  542.  
  543. void CWinHTTrackApp::OnFileSaveAs() 
  544. {
  545.     // TODO: Add your command handler code here
  546.     
  547. }
  548.  
  549. void CWinHTTrackApp::OnFileDelete()
  550. {
  551.   static char szFilter[256];
  552.   strcpy(szFilter,"WinHTTrack Website Copier Project (*.whtt)|*.whtt||");
  553.   CFileDialog* dial = new CFileDialog(true,"whtt",NULL,OFN_HIDEREADONLY,szFilter);
  554.   if (dial->DoModal() == IDOK) {
  555.     CString st=dial->GetPathName();
  556.     if (fexist((char*) LPCTSTR(st))) {
  557.       int pos=st.ReverseFind('.');
  558.       CString dir=st.Left(pos)+"\\";
  559.       char msg[1000];
  560.       sprintf(msg,"%s\r\n%s",LANG_DELETECONF,dir);
  561.       if (AfxMessageBox(msg,MB_OKCANCEL)==IDOK) {
  562.         if (remove(st)) {
  563.           AfxMessageBox("Error deleting "+st);
  564.         } else {
  565.           RmDir(dir);
  566.         }
  567.       }
  568.     } else
  569.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  570.   }
  571.   delete dial;
  572. }
  573.  
  574. void CWinHTTrackApp::OnBrowseWebsites()
  575. {
  576.   CString st=dialog0->GetBasePath();
  577.  
  578.   if (st.GetLength()<=1) {
  579.     CString strSection       = "DefaultValues";    
  580.     CWinApp* pApp = AfxGetApp();
  581.     st = pApp->GetProfileString(strSection, "BasePath");
  582.     st += "\\";
  583.   }
  584.  
  585.   st+="index.html";
  586.   ShellExecute(NULL,"open",st,"","",SW_RESTORE);    
  587. }
  588.  
  589. BOOL CWinHTTrackApp::RmDir(CString srcpath) {
  590.   CWaitCursor wait;
  591.  
  592.   if (srcpath.GetLength()==0)
  593.     return FALSE;
  594.   CString path=srcpath;
  595.   WIN32_FIND_DATA find;
  596.   if (path.Right(1)!="\\")
  597.     path+="\\";  
  598.   HANDLE h = FindFirstFile(path+"*.*",&find);
  599.   if (h != INVALID_HANDLE_VALUE) {
  600.     do {
  601.       if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_SYSTEM ))
  602.       if (strcmp(find.cFileName,".."))
  603.       if (strcmp(find.cFileName,"."))
  604.         if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY )) {
  605.           if (remove(path+find.cFileName)) {
  606.             AfxMessageBox("Error deleting "+path+find.cFileName);
  607.             return FALSE;
  608.           }
  609.         } else {
  610.           if (!RmDir(path+find.cFileName))
  611.             return FALSE;
  612.         }
  613.     } while(FindNextFile(h,&find));
  614.     FindClose(h);
  615.   }
  616.   if (rmdir(srcpath)) {
  617.     AfxMessageBox("Error deleting "+srcpath);
  618.     return FALSE;
  619.   }
  620.   return TRUE;
  621. }
  622.  
  623.  
  624. void CWinHTTrackApp::OnFileMruFile1() 
  625. {
  626.     // TODO: Add your command handler code here
  627.     
  628. }
  629.  
  630. void CWinHTTrackApp::Onipabout() 
  631. {
  632.   Cabout about;
  633.   about.DoModal();
  634. }
  635.  
  636. void CWinHTTrackApp::OnUpdate() 
  637. {
  638.   CString st;
  639.   st.Format(HTS_UPDATE_WEBSITE,HTS_PLATFORM,LANGUAGE_NAME);
  640.   HtsHelper->Help(st);
  641. }
  642.  
  643. // Appel aide
  644. BOOL CWinHTTrackApp::OnHelpInfo2() {
  645.   return OnHelpInfo(NULL);
  646. }
  647.  
  648. BOOL CWinHTTrackApp::OnHelpInfo(HELPINFO* dummy) 
  649. {
  650.   HtsHelper->Help("step2.html");
  651.   return true;
  652. }
  653.  
  654. // Forwards
  655.  
  656. void CWinHTTrackApp::FwOnhide() {
  657.   if (this_CSplitterFrame)
  658.     this_CSplitterFrame->Onhide();
  659.   else
  660.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  661. }
  662.  
  663. void CWinHTTrackApp::FwOnLoadprofile() {
  664.   if ((dialog1!=NULL) && (maintab!=NULL))
  665.     dialog1->OnLoadprofile();
  666.   else
  667.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  668. }
  669. void CWinHTTrackApp::FwOnSaveprofile() {
  670.   if ((dialog1!=NULL) && (maintab!=NULL))
  671.     dialog1->OnSaveprofile();
  672.   else
  673.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  674. }
  675. void CWinHTTrackApp::FwOnLoaddefault() {
  676.   if ((dialog1!=NULL) && (maintab!=NULL))
  677.     dialog1->OnLoaddefault();
  678.   else
  679.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  680. }
  681. void CWinHTTrackApp::FwOnSavedefault() {
  682.   if ((dialog1!=NULL) && (maintab!=NULL))
  683.     dialog1->OnSavedefault();
  684.   else
  685.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  686. }
  687. void CWinHTTrackApp::FwOnResetdefault() {
  688.   if ((dialog1!=NULL) && (maintab!=NULL))
  689.     dialog1->OnResetdefault();
  690.   else
  691.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  692. }
  693.  
  694. //
  695.  
  696. void CWinHTTrackApp::FwOnModifyOpt() {
  697.   if ((inprogress!=NULL) && (maintab!=NULL))
  698.     inprogress->OnModifyOpt();
  699.   else
  700.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  701. }
  702.  
  703. void CWinHTTrackApp::FwOnPause() {
  704.   if ((inprogress!=NULL) && (maintab!=NULL))
  705.     inprogress->OnPause();
  706.   else
  707.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  708. }
  709.  
  710. void CWinHTTrackApp::FwOniplogLog() {
  711.   if ((inprogress!=NULL) && (maintab!=NULL))
  712.     inprogress->OniplogLog();
  713.   else
  714.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  715. }
  716.  
  717. void CWinHTTrackApp::FwOniplogErr() {
  718.   if ((inprogress!=NULL) && (maintab!=NULL))
  719.     inprogress->OniplogErr();
  720.   else
  721.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  722. }
  723.  
  724. void CWinHTTrackApp::FwOnViewTransfers() {
  725.   if ((inprogress!=NULL) && (maintab!=NULL))
  726.     inprogress->OnViewTransfers();
  727.   else
  728.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  729. }
  730.  
  731. CDocument* CWinHTTrackApp::OpenDocumentFile( LPCTSTR lpszFileName)
  732. {
  733.   // Eviter deux fenΩtres (un seul document)
  734.   // Le CMultui..->CSingleDoc.. est trop complexe α changer (α cause du splitter-wnd)
  735.   int count=1;
  736.  
  737.   { /* Check if a document exists, and if exists if empty or not, and if name is different */
  738.     POSITION pos;
  739.     pos=GetFirstDocTemplatePosition();
  740.     if (pos) {
  741.       CDocTemplate* tmpl=GetNextDocTemplate(pos);
  742.       if (tmpl) {
  743.         pos=tmpl->GetFirstDocPosition();
  744.         if (pos) {
  745.           CDocument* doc  = tmpl->GetNextDoc(pos);
  746.           if (doc) {
  747.             if (dialog0->GetName().GetLength()==0) {
  748.               CloseAllDocuments(FALSE);
  749.               count=0;        /* No documents */
  750.             } else {
  751.               if (dialog0->GetPath0()+".whtt" == LPCSTR(lpszFileName))
  752.                 return NULL;
  753.             }
  754.           }
  755.         } else
  756.           count=0;          /* No documents */
  757.       }
  758.     }
  759.   }
  760.  
  761.   // Ouvrir nouvelle instance
  762.   if (count) {
  763.     char cmdl[2048];
  764.     CWinApp* pApp = AfxGetApp();
  765.     CString name = pApp->m_pszHelpFilePath;
  766.     name=name.Left(name.GetLength()-4);
  767.     name += ".EXE";
  768.     strcpy(cmdl,"\"");
  769.     strcat(cmdl,lpszFileName);
  770.     strcat(cmdl,"\"");
  771.     ShellExecute(NULL,"open",name,cmdl,"",SW_RESTORE);
  772.     return NULL;
  773.   }
  774.  
  775.   // Ouvrir nouveau?
  776.   //if (count)
  777.   //  return;       // ne rien faire, car limitΘ α 1 document
  778.   //count++;
  779.  
  780.   /* Ouvrir */
  781.   /*
  782.   CWinApp* app=AfxGetApp();
  783.   POSITION pos;
  784.   pos=app->GetFirstDocTemplatePosition();
  785.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  786.   pos=templ->GetFirstDocPosition();
  787.   if (pos) {
  788.     CDocument* doc  = templ->GetNextDoc(pos);
  789.     if (doc)
  790.       if (!doc->SaveModified())
  791.         return NULL;
  792.   }
  793.   CloseAllDocuments(FALSE);
  794.   */
  795.   if (strlen(lpszFileName))
  796.     return CWinApp::OpenDocumentFile(lpszFileName);
  797.   else
  798.     CWinApp::OnFileNew();
  799.   return NULL;
  800. }
  801.  
  802. void CWinHTTrackApp::NewTabs() {
  803.   DeleteTabs();
  804.   m_tab0 = new CFirstInfo();
  805.   m_tab1 = new CNewProj();
  806.   m_tab2 = new Wid1();
  807.   m_tab3 = new Ctrans();
  808.   m_tabprogress = new Cinprogress();
  809.   m_tabend = new Cinfoend();
  810. }
  811.  
  812. void CWinHTTrackApp::DeleteTabs() {
  813.   if (m_tab0)
  814.   if (m_tab0->GetSafeHwnd())       /* a dΘja ΘtΘ dΘtruit par CWinApp */
  815.     delete m_tab0;
  816.   if (m_tab1)
  817.   if (m_tab1->GetSafeHwnd())
  818.     delete m_tab1;
  819.   if (m_tab2)
  820.   if (m_tab2->GetSafeHwnd())
  821.     delete m_tab2;
  822.   if (m_tab3)
  823.   if (m_tab3->GetSafeHwnd())
  824.     delete m_tab3;
  825.   if (m_tabprogress)
  826.   if (m_tabprogress->GetSafeHwnd())
  827.     delete m_tabprogress;
  828.   if (m_tabend)
  829.   if (m_tabend->GetSafeHwnd())
  830.     delete m_tabend;
  831.  
  832.   m_tab0=NULL;
  833.   m_tab1=NULL;
  834.   m_tab2=NULL;
  835.   m_tab3=NULL;
  836.   m_tabprogress=NULL;
  837.   m_tabend=NULL;
  838. }
  839.  
  840. int CWinHTTrackApp::ExitInstance() 
  841. {
  842.   LANG_DELETE();
  843.  
  844.   /* Uninitialize */
  845.   hts_uninit();
  846.  
  847.   return CWinApp::ExitInstance();
  848. }
  849.